#!/bin/sh

pid=`ps aux | grep tomcat | grep -v grep | grep -v retomcat | awk '{print $2}'`
echo $pid

if [ -n "$pid" ]
then
{
   echo ===========shutdown================
   /opt/ding/api-tomcat/bin/shutdown.sh
   sleep 1
   pid=`ps aux | grep tomcat | grep -v grep | grep -v retomcat | awk '{print $2}'`
   if [ -n "$pid" ]
   then
    {
      sleep 1
      echo ========kill tomcat==============
      kill -9 $pid
    }
   fi
   sleep 1
   echo ===========startup.sh==============
   /opt/ding/api-tomcat/bin/startup.sh
 }
else
echo ===========startup.sh==============
/opt/ding/api-tomcat/bin/startup.sh
fi